﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Input;
using System.Windows;
using System.Diagnostics;

namespace MedicalInterface.ViewModel
{
    public class RemUserViewModel : BaseViewModel
    {
        #region variables
        private bool _closeSignal;
        private bool? _dialogResult;
        private string _msg;

        #endregion


        #region commandes
        private ICommand _cmd_ok;
        private ICommand _cmd_cancel;
        #endregion
 
        #region getter / setter

        /// <summary>
        /// indique si on doit fermer la fenêtre ou non
        /// </summary>
        public bool CloseSignal
        {
            get { return _closeSignal; }
            set
            {
                if (_closeSignal != value)
                {
                    _closeSignal = value;
                    OnPropertyChanged("CloseSignal");
                }
            }
        }
        /// <summary>
        /// "return" de la fenetre
        /// </summary>
        public bool? DialogResult
        {
            get { return _dialogResult; }
            set
            {
                if (_dialogResult != value)
                {
                    _dialogResult = value;
                    OnPropertyChanged("DialogResult");
                }
            }
        }
        /// <summary>
        /// command pour OK
        /// </summary>
        public ICommand cmd_ok
        {
            get
            {
                if (_cmd_ok == null)
                {
                        _cmd_ok = new RelayCommand(Confirm, CanOk);
                }
                return _cmd_ok;
            }
            set { _cmd_ok = value; }
        }

        /// <summary>
        /// command pour Cancel
        /// </summary>
        public ICommand cmd_cancel
        {
            get
            {
                if (_cmd_cancel == null)
                {
                    _cmd_cancel = new RelayCommand(Cancel, CanCancel);
                }
                return _cmd_cancel;
            }
            set { _cmd_cancel = value; }
        }
        
        /// <summary>
        /// Variable qui contient le msg de la TextBlock
        /// </summary>
        public string diag_msg
        {
            get { return _msg; }
            set { _msg = value; }
        }

        #endregion


        /// <summary>
        /// constructeur
        /// </summary>
        public RemUserViewModel(string login)
        {
            //init variables
            _msg = "Voulez-vous supprimer '"+login+"' de la liste utilisateur ?";
        }

        /// <summary>
        /// Le bouton OK est-il accessible?
        /// </summary>
        /// <param name="parameter">Type Object</param>
        /// <returns>True</returns>
        private bool CanOk(object parameter)
        {
            return true;
        }

        /// <summary>
        /// Le bouton Cancel est-il accessible?
        /// </summary>
        /// <param name="parameter">Type Object</param>
        /// <returns></returns>
        private bool CanCancel(object parameter)
        {
            return true;
        }

        
        
        private void Confirm(object parameter)
        {
            DialogResult = true;
            CloseSignal = true;
        }
        private void Cancel(object parameter)
        {
            DialogResult = false;
            CloseSignal = true;
        }

    }
}
